package com.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.utils.IdGen;
import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

public class BaseEntity implements Serializable {

    private static final long serialVersionUID = 4137887642727214567L;
    protected String id;


    /**
     * 插入之前执行方法，初始化公共属性
     *
     * @return
     */
    public String preInsert() {
        String id = getId();
        if (StringUtils.isBlank(id)){
            id = IdGen.uuid();
        }
        setId(id);

        return id;
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}
